1. Field of the Invention
The present invention relates to the design of disassemblers for converting machine code for a computer program into corresponding human-readable assembly code. More specifically, the present invention relates to a method and an apparatus for implementing a multi-mode specification-driven disassembler.
2. Related Art
During development of an application for a computer system, developers typically write source code for the application in a higher-level language (HLL). This source code version of the application is then translated by a compiler (or an assembler) into corresponding machine code version of the program that is suitable for execution on a specific target computer system.
To ensure correctness, developers often desire to examine the machine code created by the compiler (or assembler). Unfortunately, this machine code is comprised of a series of numbers that cannot easily be deciphered by even the most knowledgeable programmers. Hence, developers typically examine the machine code by first using a disassembler to translate the machine code into human-readable assembly code. This assembly code uses descriptive mnemonics to represent program instructions, and these mnemonics are more understandable to a human than the corresponding machine code numbers.
Some instruction set architectures, such as the instruction set architecture for the PowerPC, define instructions—such as branches and traps—that are so general that the general form verges on incomprehensibility. For example, an instruction that branches on equality might be written as,                bc 12, 2,<destination>.To simplify life for the programmer, the PowerPC assembler also defines a shorthand representation for the same instruction, so that the instruction can be more intuitively represented as        beq<destination>.        
While it is no problem for the assembler to generate the same bits for these two different mnemonics, the disassembler, which operates in the reverse direction, must choose one form or the other when it disassembles the bits for such an instruction.
Current disassemblers are designed to choose one source form, typically the most specific, such as the beq <destination> form. While this most-specific form is usually desired, the most general form is useful in specific situations, particularly for debugging compilers.
What is needed is a method and an apparatus that allows the user to control the assembly code form that the disassembler chooses while disassembling machine code.